﻿using Microsoft.AspNetCore.Http;
using Microsoft.AspNetCore.Mvc;
using MediatR;
using W.Purchase.API.Application.Command;
using W.Purchase.Domain;
using Microsoft.AspNetCore.Authorization;
namespace W.Purchase.API.Controllers
{
    [Route("api/[controller]/[action]")]
    [ApiController]
    //[Authorize]
    public class VendorController : ControllerBase
    {
        private readonly IMediator mediator;

        public VendorController(IMediator mediator)
        {
            this.mediator = mediator;
        }
        /// <summary>
        /// 供应商添加
        /// </summary>
        /// <param name="command"></param>
        /// <returns>返回影响行数</returns>
        [HttpPost]
        public async Task<int> VendorAdd(VendorAddCommand command)
        {
            return await mediator.Send(command);
        }
        /// <summary>
        /// 供应商删除
        /// </summary>
        /// <param name="command"></param>
        /// <returns>返回影响行数</returns>
        [HttpPost]
        public async Task<int> VendorDelete(VendorDeleteCommand command)
        {
            return await mediator.Send(command);
        }
        /// <summary>
        /// 供应商反填
        /// </summary>
        /// <param name="command"></param>
        /// <returns>返回集合</returns>
        [HttpPost]
        public async Task<List<Vendor>> VendorFan(VendorFanCommand command)
        {
            return await mediator.Send(command);
        }
        /// <summary>
        /// 供应商修改
        /// </summary>
        /// <param name="command"></param>
        /// <returns>返回影响行数</returns>
        [HttpPost]
        public async Task<int> VendorUpdate(VendorUpdateCommand command)
        {
            return await mediator.Send(command);
        }
        /// <summary>
        /// 供应商批量删除
        /// </summary>
        /// <param name="command"></param>
        /// <returns>返回影响行数</returns>
        [HttpPost]
        public async Task<int> VendorIsdelAll(VendorIsdelAllcommand command)
        {
            return await mediator.Send(command);
        }
    }
}
